Optimal. Leaf size=82 \[ \frac {b \cos (x)}{a^2}+\frac {x \left (a^2+2 b^2\right )}{2 a^3}+\frac {2 b^3 \tanh ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{a^3 \sqrt {a^2-b^2}}-\frac {\sin (x) \cos (x)}{2 a} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.26, antiderivative size = 82, normalized size of antiderivative = 1.00, number of steps used = 7, number of rules used = 7, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.538, Rules used = {3853, 4104, 3919, 3831, 2660, 618, 206} \[ \frac {x \left (a^2+2 b^2\right )}{2 a^3}+\frac {2 b^3 \tanh ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{a^3 \sqrt {a^2-b^2}}+\frac {b \cos (x)}{a^2}-\frac {\sin (x) \cos (x)}{2 a} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 206
Rule 618
Rule 2660
Rule 3831
Rule 3853
Rule 3919
Rule 4104
Rubi steps
\begin {align*} \int \frac {\sin ^2(x)}{a+b \csc (x)} \, dx &=-\frac {\cos (x) \sin (x)}{2 a}+\frac {\int \frac {\left (-2 b+a \csc (x)+b \csc ^2(x)\right ) \sin (x)}{a+b \csc (x)} \, dx}{2 a}\\ &=\frac {b \cos (x)}{a^2}-\frac {\cos (x) \sin (x)}{2 a}-\frac {\int \frac {-a^2-2 b^2-a b \csc (x)}{a+b \csc (x)} \, dx}{2 a^2}\\ &=\frac {\left (a^2+2 b^2\right ) x}{2 a^3}+\frac {b \cos (x)}{a^2}-\frac {\cos (x) \sin (x)}{2 a}-\frac {b^3 \int \frac {\csc (x)}{a+b \csc (x)} \, dx}{a^3}\\ &=\frac {\left (a^2+2 b^2\right ) x}{2 a^3}+\frac {b \cos (x)}{a^2}-\frac {\cos (x) \sin (x)}{2 a}-\frac {b^2 \int \frac {1}{1+\frac {a \sin (x)}{b}} \, dx}{a^3}\\ &=\frac {\left (a^2+2 b^2\right ) x}{2 a^3}+\frac {b \cos (x)}{a^2}-\frac {\cos (x) \sin (x)}{2 a}-\frac {\left (2 b^2\right ) \operatorname {Subst}\left (\int \frac {1}{1+\frac {2 a x}{b}+x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{a^3}\\ &=\frac {\left (a^2+2 b^2\right ) x}{2 a^3}+\frac {b \cos (x)}{a^2}-\frac {\cos (x) \sin (x)}{2 a}+\frac {\left (4 b^2\right ) \operatorname {Subst}\left (\int \frac {1}{-4 \left (1-\frac {a^2}{b^2}\right )-x^2} \, dx,x,\frac {2 a}{b}+2 \tan \left (\frac {x}{2}\right )\right )}{a^3}\\ &=\frac {\left (a^2+2 b^2\right ) x}{2 a^3}+\frac {2 b^3 \tanh ^{-1}\left (\frac {b \left (\frac {a}{b}+\tan \left (\frac {x}{2}\right )\right )}{\sqrt {a^2-b^2}}\right )}{a^3 \sqrt {a^2-b^2}}+\frac {b \cos (x)}{a^2}-\frac {\cos (x) \sin (x)}{2 a}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A] time = 0.11, size = 78, normalized size = 0.95 \[ \frac {-\frac {8 b^3 \tan ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {b^2-a^2}}\right )}{\sqrt {b^2-a^2}}+2 a^2 x-a^2 \sin (2 x)+4 a b \cos (x)+4 b^2 x}{4 a^3} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
fricas [A] time = 0.68, size = 285, normalized size = 3.48 \[ \left [\frac {\sqrt {a^{2} - b^{2}} b^{3} \log \left (\frac {{\left (a^{2} - 2 \, b^{2}\right )} \cos \relax (x)^{2} + 2 \, a b \sin \relax (x) + a^{2} + b^{2} + 2 \, {\left (b \cos \relax (x) \sin \relax (x) + a \cos \relax (x)\right )} \sqrt {a^{2} - b^{2}}}{a^{2} \cos \relax (x)^{2} - 2 \, a b \sin \relax (x) - a^{2} - b^{2}}\right ) - {\left (a^{4} - a^{2} b^{2}\right )} \cos \relax (x) \sin \relax (x) + {\left (a^{4} + a^{2} b^{2} - 2 \, b^{4}\right )} x + 2 \, {\left (a^{3} b - a b^{3}\right )} \cos \relax (x)}{2 \, {\left (a^{5} - a^{3} b^{2}\right )}}, \frac {2 \, \sqrt {-a^{2} + b^{2}} b^{3} \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \sin \relax (x) + a\right )}}{{\left (a^{2} - b^{2}\right )} \cos \relax (x)}\right ) - {\left (a^{4} - a^{2} b^{2}\right )} \cos \relax (x) \sin \relax (x) + {\left (a^{4} + a^{2} b^{2} - 2 \, b^{4}\right )} x + 2 \, {\left (a^{3} b - a b^{3}\right )} \cos \relax (x)}{2 \, {\left (a^{5} - a^{3} b^{2}\right )}}\right ] \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
giac [A] time = 0.64, size = 112, normalized size = 1.37 \[ -\frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\relax (b) + \arctan \left (\frac {b \tan \left (\frac {1}{2} \, x\right ) + a}{\sqrt {-a^{2} + b^{2}}}\right )\right )} b^{3}}{\sqrt {-a^{2} + b^{2}} a^{3}} + \frac {{\left (a^{2} + 2 \, b^{2}\right )} x}{2 \, a^{3}} + \frac {a \tan \left (\frac {1}{2} \, x\right )^{3} + 2 \, b \tan \left (\frac {1}{2} \, x\right )^{2} - a \tan \left (\frac {1}{2} \, x\right ) + 2 \, b}{{\left (\tan \left (\frac {1}{2} \, x\right )^{2} + 1\right )}^{2} a^{2}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maple [A] time = 0.49, size = 142, normalized size = 1.73 \[ -\frac {2 b^{3} \arctan \left (\frac {2 \tan \left (\frac {x}{2}\right ) b +2 a}{2 \sqrt {-a^{2}+b^{2}}}\right )}{a^{3} \sqrt {-a^{2}+b^{2}}}+\frac {\tan ^{3}\left (\frac {x}{2}\right )}{a \left (\tan ^{2}\left (\frac {x}{2}\right )+1\right )^{2}}+\frac {2 b \left (\tan ^{2}\left (\frac {x}{2}\right )\right )}{a^{2} \left (\tan ^{2}\left (\frac {x}{2}\right )+1\right )^{2}}-\frac {\tan \left (\frac {x}{2}\right )}{a \left (\tan ^{2}\left (\frac {x}{2}\right )+1\right )^{2}}+\frac {2 b}{a^{2} \left (\tan ^{2}\left (\frac {x}{2}\right )+1\right )^{2}}+\frac {2 \arctan \left (\tan \left (\frac {x}{2}\right )\right ) b^{2}}{a^{3}}+\frac {x}{2 a} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maxima [F(-2)] time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
mupad [B] time = 0.84, size = 1147, normalized size = 13.99 \[ \text {result too large to display} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
sympy [F] time = 0.00, size = 0, normalized size = 0.00 \[ \int \frac {\sin ^{2}{\relax (x )}}{a + b \csc {\relax (x )}}\, dx \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________